package com.ruoyi.project.card.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.framework.aspectj.lang.annotation.Anonymous;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.card.domain.AlumniSwiper;
import com.ruoyi.project.card.service.IAlumniSwiperService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 轮播图管理Controller
 *
 * @author hongwj
 * @date 2024-05-03
 */
@RestController
@RequestMapping("/card/swiper" )
@Slf4j
public class AlumniSwiperController extends BaseController {
    @Autowired
    private IAlumniSwiperService alumniSwiperService;

    /**
     * 查询轮播图管理列表
     */
    @GetMapping("/list" )
    @Anonymous
    public TableDataInfo list(AlumniSwiper alumniSwiper) {
        startPage();
        List<AlumniSwiper> list = alumniSwiperService.selectAlumniSwiperList(alumniSwiper);
        return getDataTable(list);
    }

    /**
     * 查询所有轮播图管理列表
     */
    @Log(title = "轮播图管理" , businessType = BusinessType.OTHER)
    @GetMapping("/all/swipers" )
    @Anonymous
    public AjaxResult all(AlumniSwiper alumniSwiper) {
        List<AlumniSwiper> list = alumniSwiperService.selectAlumniSwiperList(alumniSwiper);
        return success(list);
    }

    /**
     * 导出轮播图管理列表
     */
    @Log(title = "轮播图管理" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    @Anonymous
    public void export(HttpServletResponse response, AlumniSwiper alumniSwiper) {
        List<AlumniSwiper> list = alumniSwiperService.selectAlumniSwiperList(alumniSwiper);
        ExcelUtil<AlumniSwiper> util = new ExcelUtil<AlumniSwiper>(AlumniSwiper. class);
        util.exportExcel(response, list, "轮播图管理数据" );
    }

    /**
     * 获取轮播图管理详细信息
     */
    @GetMapping(value = "/{id}" )
    @Anonymous
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return success(alumniSwiperService.selectAlumniSwiperById(id));
    }

    /**
     * 新增轮播图管理
     */
    @Log(title = "轮播图管理" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlumniSwiper alumniSwiper) {
        return toAjax(alumniSwiperService.insertAlumniSwiper(alumniSwiper));
    }

    /**
     * 修改轮播图管理
     */
    @Log(title = "轮播图管理" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlumniSwiper alumniSwiper) {
        return toAjax(alumniSwiperService.updateAlumniSwiper(alumniSwiper));
    }

    /**
     * 删除轮播图管理
     */
    @Log(title = "轮播图管理" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(alumniSwiperService.deleteAlumniSwiperByIds(ids));
    }
}
